# coding: utf-8
from django.db import models
from django.utils import timezone
from django.conf import settings
from common.models.base import BaseModel
from common.models.user import User


class Game(BaseModel):
    name = models.CharField(max_length=100, default='')
    template = models.CharField(max_length=100, default='')

    def __unicode__(self):
        return self.name

    class Meta:
        app_label = 'common'
        db_table = 'game_game'


class GamePlayTrace(BaseModel):
    user = models.ForeignKey(User)
    game = models.ForeignKey(Game)
    score = models.PositiveIntegerField(default=0)

    def __unicode__(self):
        return self.game.name + ' trace'

    class Meta:
        app_label = 'common'
        db_table = 'game_play_trace'


class GameRank(BaseModel):
    game = models.OneToOneField(Game)
    trace = models.ForeignKey(GamePlayTrace)

    def __unicode__(self):
        return self.game.name + ' rank'

    class Meta:
        app_label = 'common'
        db_table = 'game_rank'